package demoMod.stsconsole.powers;

import demoMod.stsconsole.characters.AbstractPlayer;
import demoMod.stsconsole.core.AbstractCreature;
import demoMod.stsconsole.interfaces.BlockSubscriber;
import demoMod.stsconsole.interfaces.TurnStartSubscriber;

public class FrailPower extends AbstractPower implements BlockSubscriber, TurnStartSubscriber {
    public static final String ID = "FrailPower";

    public FrailPower(AbstractCreature owner, int amount) {
        super(ID, owner, amount);
        this.type = PowerType.DEBUFF;
    }

    @Override
    public String getUpdatedDescriptions() {
        return String.format(this.description, this.amount[0]);
    }

    @Override
    public int onDefendToChangeBlock(int blockAmount, AbstractCreature target) {
        return (int) (blockAmount * 0.75F);
    }

    @Override
    public int getPriority() {
        return super.getPriority() + 1;
    }

    @Override
    public void atTurnStart(boolean isPlayer) {
        if (this.owner instanceof AbstractPlayer == isPlayer) {
            this.amount[0]--;
        }
        if (this.amount[0] <= 0) {
            this.onRemove();
        }
    }
}
